﻿using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;

using Ordinaire.Data;

namespace Ordinaire.Commerce.Purchasing.Data
{
    /// <summary>
    /// Use this to capture all purchase payments.
    /// </summary>
    [Table]
    public class PurchasePayments : JunctionData<Purchases, PurchaseGoods, int, string>
    {
        #region Property methods

        /// <summary>
        /// Get or set the entry unique identifier.
        /// </summary>
        [Column(IsPrimaryKey = true, IsDbGenerated = true, UpdateCheck = UpdateCheck.Never)]
        public override int Id
        {
            get { return base.Id; }
            set { base.Id = value; }
        }

        /// <summary>
        /// Gets or sets the corresponding id of related table "Purchases".
        /// </summary>
        [Column(Name = "PurchaseId", DbType = "int NOT NULL", UpdateCheck = UpdateCheck.Never)]
        public override int IdA
        {
            get { return base.IdA; }
            set { base.IdA = value; }
        }

        /// <summary>
        /// Gets or sets the record id of related table "PurchaseGoods".
        /// </summary>
        [Column(Name = "PurchaseGoodId", DbType = "int NOT NULL", UpdateCheck = UpdateCheck.Never)]
        public override int IdB
        {
            get { return base.IdB; }
            set { base.IdB = value; }
        }

        /// <summary>
        /// Gets or sets the payment date.
        /// </summary>
        [Column(DbType = "date NOT NULL", UpdateCheck = UpdateCheck.Never)]
        public DateTime Date { get; set; }

        /// <summary>
        /// Gets or sets the payment method.
        /// </summary>
        [Column(DbType = "nvarchar(25) NULL", UpdateCheck = UpdateCheck.Never)]
        public string Method { get; set; }

        /// <summary>
        /// Gets or sets the payment value.
        /// </summary>
        public decimal Value { get; set; }

        #region Overrides

        #region Overrides IAudit

        /// <summary>
        /// Get or set the username who created this entry.
        /// </summary>
        [Column(DbType = "nvarchar(10) NOT NULL", UpdateCheck = UpdateCheck.Never)]
        public override string CreatedBy
        {
            get { return base.CreatedBy; }
            set { base.CreatedBy = value; }
        }

        /// <summary>
        /// Get or set the date when the entry was first created.
        /// </summary>
        [Column(DbType = "datetime NOT NULL", UpdateCheck = UpdateCheck.Never)]
        public override DateTime? CreateDate
        {
            get { return base.CreateDate; }
            set { base.CreateDate = value; }
        }

        /// <summary>
        /// Get or set the username who last updated this entry.
        /// </summary>
        [Column(DbType = "nvarchar(10) NULL", UpdateCheck = UpdateCheck.Never)]
        public override string UpdatedBy
        {
            get { return base.UpdatedBy; }
            set { base.UpdatedBy = value; }
        }

        /// <summary>
        /// Get or set the date when the entry was last updated.
        /// </summary>
        [Column(DbType = "datetime NULL", UpdateCheck = UpdateCheck.Never)]
        public override DateTime? UpdateDate
        {
            get { return base.UpdateDate; }
            set { base.UpdateDate = value; }
        }

        #endregion

        #region JunctionData

        /// <summary>
        /// Gets or sets value of the related table "Purchases".
        /// </summary>
        [Association(Name = "FK_PurchasePayments_Purchases", IsForeignKey = true, ThisKey = "IdA", OtherKey = "Id", Storage = "dataA")]
        public override Purchases DataA
        {
            get { return base.DataA; }
            set { base.DataA = value; }
        }

        /// <summary>
        /// Gets or sets the corresponding data in table "Goods".
        /// </summary>
        [Association(Name = "FK_PurchasePayments_PurchaseGoods", ThisKey = "IdB", OtherKey = "Id", Storage = "dataB")]
        public override PurchaseGoods DataB
        {
            get { return base.DataB; }
            set { base.DataB = value; }
        }

        #endregion

        #endregion

        #endregion
    }
}
